# Doclib Compliance Tag
Applies a compliance (retention) label to a document library and optionally to all existing items, by processing rows from an Excel file.
Filename pattern: filename must contain DoclibComplianceTag (case-insensitive).
Example: 20240115 DoclibComplianceTag retention.xlsx
# Columns
| Name | Required | Description |
|---|---|---|
| Url | Conditional | Server-relative URL of the document library. Required when MatterCode is not provided. |
| MatterCode | Conditional | Matter code used to resolve document libraries from the matter list. Required when Url is not provided. Applies to all document libraries for the matter. |
| ClientCode | No | Client code used together with MatterCode to identify the matter. |
| Label | No | Name of the compliance/retention label to apply. If omitted, the label policy is updated without changing the label. |
| BlockForEdit | No | Boolean. Whether to block editing of labeled items. |
| BlockForDelete | No | Boolean. Whether to block deletion of labeled items. |
| ApplyToExistingItems | No | Boolean. true applies the label to all items already in the library. Defaults to false (applies to new items only). |
| Properties | No | Any additional columns are passed as properties to the compliance policy update. |
Either Url or MatterCode must be provided.
# Behavior
Applies the specified compliance/retention label policy to the resolved document library. When ApplyToExistingItems is true, the label is also applied to all items already in the library; otherwise only the library-level policy is updated and new items inherit the label.
# Related links
- Doclib Set handler — apply full document library configuration
- Update Doclib File Sensitivity Label handler — apply a Microsoft Purview sensitivity label to files